<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
.ftitle{
    font-size:14px;
    font-weight:bold;
    padding:5px 0;
    margin-bottom:10px;
    border-bottom:1px solid #ccc;
}
.fitem{
    margin-bottom:10px;
}
.fitem label{
    display:inline-block;
    font-weight:bold;
    text-align:center;
    width: 29%;
}
</style>
</head>
<body style="padding: 5px">
<form id="form1" method="post">
	<div class="fitem">
		<label>所在部门：</label>
		<input id="input0001" class="mini-combobox" name="deptType" required="true" style="width: 220px" onValueChanged="onDeptChanged" data="[{id:'cm',text:'话务中心'},{id:'om',text:'订单中心'}]" />
	</div>
	<div class="fitem">
		<label>所在中心：</label>
		<input id="combo1" name="platformType" class="mini-combobox" style="width:220px;" textField="name" valueField="id" 
    				allowInput="false" required="true" onValueChanged="onPlatChanged" />
    </div>
    <div class="fitem">
		<label>所在组：</label>
		<input id="combo2" name="groupType" class="mini-combobox" style="width:220px;" textField="name" valueField="id" 
    				allowInput="false" required="true" />
    </div>
	<div class="fitem">
		<label>职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位：</label>
		<input id="input0022" class="mini-combobox" name="isLeader" required="true" style="width: 220px" onValueChanged="onPositionChanged" data="[{id:'1',text:'组长'},{id:'2',text:'组员'}]" />
	</div>
	<div class="fitem">
		<label>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</label>
		<input id="input0298" name="uid" class="mini-combobox" required="true"
			style="width: 220px;" textField="name" valueField="id" popupHeight="100"/>
	</div>
	<div class="fitem">
		<label>基本工资：</label>
		<input name="basic" class="mini-textbox" vtype="float" required="true" maxLength="9" style="width: 220px"/><b>元</b>
	</div>
</form>
<div style="text-align:center;padding-top: 45px;">
    <a class="mini-button" onclick="saveBasic();" style="width:60px;margin-right:20px;">确定</a>       
    <a class="mini-button" onclick="window.CloseOwnerWindow();" style="width:60px;">取消</a>       
</div>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
var deptCombo = mini.get("input0001");
var platform = mini.get("combo1");
var group = mini.get("combo2");
var positionCombo = mini.get("input0022");
var staffCombo = mini.get("input0298");


function saveBasic(){
	var o = form.getData(); 
    form.validate();
    if (form.isValid() == false) return;
    $.post("include_staff_user.do", {uid: staffCombo.getValue()}, function(data){
    	if(data.success) {
    		$.post("staff_basic_save.do",o,function(text){
    	    	if(text.success){
    	        	window.CloseOwnerWindow("succ");
    	        }else{
    	        	mini.alert("数据错误！");
    	        }
    	    },"json");
    	} else {
    		mini.alert("此用户已设置基本工资");
    	}
    }, "json");
}

function onDeptChanged(e) {
    positionCombo.setValue("");
    staffCombo.setValue("");
}

function onDeptChanged() {
	var dept = deptCombo.getValue();
	if('cm' == dept) {
		platform.load("platform_view_list.do?type=2");
	} else if('om' == dept){
		platform.load("platform_view_list.do?type=3");
	} else {}
	platform.select(0);
	onPlatChanged();
}

function onPlatChanged() {
	var plat = platform.getValue();
	if(plat) {
		group.load("group_view_list.do?platformId="+plat);
		group.select(0);
		onPositionChanged();
	} else {
		group.setValue(null);
	}
}

function onPositionChanged() {
	var dept = deptCombo.getValue();
	var position = positionCombo.getValue();
	if(dept){
		if(position) {
			var urls = "staff_specific_staff.do?dept="+dept+"&position="+position;
			staffCombo.setUrl(urls);
			staffCombo.select(0);
		}
	}else{
		mini.alert("请选择部门");
		positionCombo.setValue(null);
	}
}

</script>
</body>
</html>